package com.bwie.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.bwie.pojo.TbServerItem;
import com.bwie.service.TbServerItemService;
import com.bwie.utils.Result;
import com.bwie.vo.ItemPageVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.CollectionUtils;
import org.springframework.web.bind.annotation.*;

import java.math.BigDecimal;

@RestController
@RequestMapping("/item/item")
public class ItemController {


    @Autowired
    TbServerItemService tbServerItemService;

    /**
     * @description 服务分页列表
     * @params [itemPageVo]
     * @return com.bwie.utils.Result
     * @author 杰
     * @date 2025/7/11 14:46
     */
    @PostMapping("/queryItemList")
    public Result queryItemList(@RequestBody ItemPageVo itemPageVo){

      return tbServerItemService.queryItemList(itemPageVo);
    }


    /**
     * @description 类型列表
     * @params []
     * @return com.bwie.utils.Result
     * @author 杰
     * @date 2025/7/11 14:55
     */

    @PostMapping("/queryItemTypeList")
    public Result queryItemTypeList(){

        return tbServerItemService.queryItemTypeList();
    }


    /**
     * @description 字典表单位
     * @params [dictTypeId]
     * @return com.bwie.utils.Result
     * @author 杰
     * @date 2025/7/11 15:15
     */
    @PostMapping("/queryDictListByTyeId/{dictTypeId}")
    public Result queryDictListByTyeId(@PathVariable("dictTypeId") Integer dictTypeId){

        return tbServerItemService.queryDictListByTyeId(dictTypeId);
    }

    /**
     * @description 添加服务
     * @params [tbServerItem]
     * @return com.bwie.utils.Result
     * @author 杰
     * @date 2025/7/11 15:17
     */
    @PostMapping("SaveServerItem")
    public Result SaveServerItem(@RequestBody TbServerItem tbServerItem){

        return tbServerItemService.SaveServerItem(tbServerItem);
    }


    @GetMapping("/queryItemPriceByItemId/{itemId}")
    public BigDecimal queryItemPriceByItemId(@PathVariable("itemId") Integer itemId){
        return tbServerItemService.queryItemPriceByItemId(itemId);
    }


}
